package com.socool;

import com.socool.facebook.Act_Login_FB;
import com.socool.manager.Manager_Shared;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

public class Act_Intro extends Activity {

	String isLogin;
	private static final int FB_Login = 0; 
	
	final static String LOG_TAG="test";
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Manager_Shared mManagerShared = new Manager_Shared(this);
		isLogin =	mManagerShared.getPref_LoginStatus();
		

		Handler handler = new Handler() {

			public void handleMessage(Message msg) {
				Intent intent = null;
				if (isLogin.equals("null")) {
					intent = new Intent(Act_Intro.this, Act_Login.class);
					if (intent != null) {
						startActivity(intent);
						overridePendingTransition(R.anim.fade, R.anim.hold);
						finish();
					}

				}else if(isLogin.equals("facebook")){

					  intent = new Intent(Act_Intro.this, Act_Login_FB.class);
					  startActivityForResult(intent, FB_Login);
						
					
				}else if(isLogin.equals("normal")){
					
				}

				

			}

		};

		handler.sendEmptyMessageDelayed(0, 2000);
	}
	
	

	public void onActivityResult(int requestCode, int resultCode, Intent intent){
		Log.d(LOG_TAG, "["+getLocalClassName()+"]"+"onActivityResult");
		super.onActivityResult(requestCode, resultCode, intent);
		 
		switch(requestCode){
		case FB_Login: // requestCode가 FB_Login 케이스
		if(resultCode == RESULT_OK){ //B_ACTIVITY에서 넘겨진 resultCode가 OK일때만 실행
		//int data = intent.getExtras().getInt("data"); //등과 같이 사용할 수 있는데, 여기서 getXXX()안에 들어있는 파라메터는 꾸러미 속 데이터의 이름표라고 보면된다.
		//Log.d("test", "data: "+data);

			// 로그인모드를 저장한다.
			Manager_Shared mManagerShared = new Manager_Shared(this);
			mManagerShared.setPref_Loginstatus("facebook");
			
		Intent i = new Intent(this, HomeActivity.class);
		
		
		startActivity(i);
		 overridePendingTransition(R.anim.fade,R.anim.hold);
		 finish();
		
		}
		break;
		}
		}


}
